package com.ihr360.payroll.model.dto.salary.embeddable;

import lombok.Getter;
import lombok.Setter;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import java.io.Serializable;

@Getter
@Setter
@Embeddable
public class StaffInfoSnapshot implements Serializable {
    @Column(length = 40, nullable = false)
    private String staffId;
    /**
     * 姓名
     */
    @Column(length = 32, nullable = false)
    private String staffName;
    /**
     * 证件类型(直接存名称)
     */
    @Column(length = 20, nullable = false)
    private String idCardType;
    /**
     * 证件号
     */
    @Column(length = 30, nullable = false)
    private String idCardNo;

    /**
     * 手机号
     */
    @Column(length = 18, nullable = false)
    private String mobileNo;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        StaffInfoSnapshot snapshot = (StaffInfoSnapshot) o;

        if (staffId != null ? !staffId.equals(snapshot.staffId) : snapshot.staffId != null) return false;
        if (staffName != null ? !staffName.equals(snapshot.staffName) : snapshot.staffName != null) return false;
        if (idCardType != null ? !idCardType.equals(snapshot.idCardType) : snapshot.idCardType != null) return false;
        if (idCardNo != null ? !idCardNo.equals(snapshot.idCardNo) : snapshot.idCardNo != null) return false;
        return !(mobileNo != null ? !mobileNo.equals(snapshot.mobileNo) : snapshot.mobileNo != null);

    }

    @Override
    public int hashCode() {
        int result = staffId != null ? staffId.hashCode() : 0;
        result = 31 * result + (staffName != null ? staffName.hashCode() : 0);
        result = 31 * result + (idCardType != null ? idCardType.hashCode() : 0);
        result = 31 * result + (idCardNo != null ? idCardNo.hashCode() : 0);
        result = 31 * result + (mobileNo != null ? mobileNo.hashCode() : 0);
        return result;
    }
}